package com.gallsoft.games.bennyadv;

import com.gallsoft.games.framework.gl.TextureRegion;
import com.gallsoft.games.framework.math.Rectangle;

public class MovingPlatform extends Platform {

    //public static final float PLATFORM_WIDTH = 2;
    //public static final float PLATFORM_WIDTH = 1.0f;
    //public static final float PLATFORM_HEIGHT = 1.0f;
    //public static final float PLATFORM_VELOCITY = 2;
    
    TextureRegion platformGraphic;
    //float stateTime;
    float minX, maxX;
    boolean isMoving;

    public MovingPlatform(float x, float y, float width, float height, float minX, float maxX, float velocity, TextureRegion platformGraphic, boolean moving) {
        super(0, x, y, platformGraphic, false, 0);

        this.platformGraphic = platformGraphic;
        //this.stateTime = 0;
        this.velocity.x = velocity;
        this.velocity.y = 0.0f;
        this.minX = minX;
        this.maxX= maxX;
        this.width = width;
        this.height = height;
        
        this.bounds = new Rectangle(x - width / 2, y - height / 2, width, height);
        isMoving = moving;
    }

    
    public void update(float deltaTime) {
        if (!isMoving)
            return;
        
        position.add(velocity.x * deltaTime, 0);
        bounds.lowerLeft.set(position).sub(width / 2, height / 2);

        if (position.x < minX) {
            velocity.x = -velocity.x;
            position.x = minX;
        }
        if (position.x > maxX) {
            velocity.x = -velocity.x;
            position.x = maxX;
        }

        //stateTime += deltaTime;
    }

    /*
    public void pulverize() {
        state = PLATFORM_STATE_PULVERIZING;
        stateTime = 0;
        velocity.x = 0;
    }
    
    
    public void adjustBoundsX(float adjust) {
        float boundsX = bounds.lowerLeft.x + adjust;
        float boundsY = bounds.lowerLeft.y;
        bounds.lowerLeft.set(boundsX, boundsY);
        bounds.width = bounds.width - adjust;
    }
    
    public void adjustBoundsWidth(float adjust) {
        bounds.width = bounds.width - adjust;
    }
    */
}
